package info
{
	import flash.display.BitmapData;
	import flash.utils.ByteArray;
	
	import starling.textures.Texture;

	public class BAAnimationInfo
	{
		
		private var _json:Object;
		
		private var _xml:XML;
		
		private var _bitmapData:BitmapData;
		private var _texture:Texture;
		
		private var _jsonByteArray:ByteArray
		 
		public function BAAnimationInfo(buff:ByteArray):void
		{
			var jsonLength:uint = buff.readUnsignedInt();
			_jsonByteArray = new ByteArray();
			buff.readBytes(_jsonByteArray,0,jsonLength);
			_jsonByteArray.position = 0;
			_json = _jsonByteArray.readObject();
			
			var xmlLength:uint = buff.readUnsignedInt();
			var xmlBytes:ByteArray = new ByteArray();
			buff.readBytes(xmlBytes,0,xmlLength);
			xmlBytes.position = 0;
			_xml = XML(xmlBytes.readUTFBytes(xmlBytes.length));
			
			var bitmapLength:uint = buff.readUnsignedInt();
			var bitmapBytes:ByteArray = new ByteArray();
			buff.readBytes(bitmapBytes,0,bitmapLength);
			bitmapBytes.position = 0;
			var width:uint = buff.readUnsignedInt();
			var height:uint = buff.readUnsignedInt();
			_bitmapData = new BitmapData(width,height);
			_bitmapData.setPixels(_bitmapData.rect,bitmapBytes);
			
			_texture = Texture.fromBitmapData(_bitmapData);
		}
		
		public function get json():Object
		{
			return _json;
		}
		
		public function get xml():XML
		{
			return _xml;
		}
		
		public function get bitmapData():BitmapData
		{
			return _bitmapData;
		}
		public function get texture():Texture
		{
			return _texture;
		}
	}
}